package com.trust.pams.service.read.impl;

import com.alibaba.dubbo.common.logger.Logger;
import com.alibaba.dubbo.common.logger.LoggerFactory;
import com.chasonx.common.model.PageResult;
import com.chasonx.common.util.Kv;
import com.chasonx.common.util.Ret;
import com.trust.pams.dao.mapper.PamsUserMapper;
import com.trust.pams.dao.service.PamsClientDao;
import com.trust.pams.dao.service.PamsMilestoneDao;
import com.trust.pams.dao.service.PamsPuoteDao;
import com.trust.pams.dao.service.PamsSvnDao;
import com.trust.pams.domain.PamsUser;
import com.trust.pams.domain.PamsUserExample;
import com.trust.pams.dto.*;
import com.trust.pams.model.Tree.Tree;
import com.trust.pams.model.query.PamsClientQuery;
import com.trust.pams.model.query.PamsQuoteQuery;
import com.trust.pams.service.es.EsQuery;
import com.trust.pams.service.read.PamsQuoteRead;
import com.trust.pams.util.DataUtil;
import com.trust.pams.util.UUIDUtil;
import org.elasticsearch.client.security.user.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.tmatesoft.svn.core.SVNDirEntry;

import javax.xml.crypto.Data;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class PamsQuoteReadImpl implements PamsQuoteRead {

    private static final Logger log = LoggerFactory.getLogger(PamsQuoteReadImpl.class);

    @Autowired
    private PamsPuoteDao pamsPuoteDao;

    @Autowired
    private PamsClientDao pamsClientDao;

    @Autowired
    private PamsMilestoneDao milestoneDao;

    @Autowired
    private PamsSvnDao svnDao;

    @Autowired
    private PamsUserMapper pamsUserMapper;

    @Override
    public Ret ListPamsQuote(PamsQuoteQuery pamsQuoteQuery) {
        try{
            PageResult<PamsQuoteDto> pageData = pamsPuoteDao.listPamsQuote(pamsQuoteQuery);
//            PageResult<Map> data = PageResult.get();
//            data.setTotalRow(pageData.getTotalRow());
//            data.setData( pageData.getData().stream().map(m -> m.getRows()).collect(Collectors.toList()));
            return Ret.get().setData(pageData).success();
        }catch (Exception e){
            log.error("listSdtmDataByPage exception => " , e);
        }
        return Ret.get().faild();
    }


    public Ret ListPamsQuotes(PamsQuoteQuery pamsQuoteQuery){
        try {
            PageResult<PamsQuoteDto>  data = EsQuery.queryQuote(pamsQuoteQuery);
            return Ret.get().setData(data).success();
        }catch (Exception e){
            log.error("ListPamsQuote exception => " , e);
        }
        return Ret.get().faild();
    }


    public Ret ListPamsQuotelast(PamsQuoteQuery pamsQuoteQuery){
        try {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");

            Calendar cal=Calendar.getInstance();

            cal.add(Calendar.DATE, -1);    //得到前一天

            cal.add(Calendar.MONTH, -1);    //得到前一个月

            long date = cal.getTimeInMillis();

            String kk=format.format(new Date(date));

            pamsQuoteQuery.setLastMonth(kk);

            PageResult<PamsQuoteDto>  data = pamsPuoteDao.listPamsQuotes(pamsQuoteQuery);

            return Ret.get().setData(data).success();
        }catch (Exception e){
            log.error("ListPamsQuote exception => " , e);
        }
        return Ret.get().faild();
    }

    public Ret getUers(String name){
        PamsUserExample pamsUserExample = new PamsUserExample();
        pamsUserExample.createCriteria().andNameEqualTo(name);
        List<PamsUser> pamsUserList= pamsUserMapper.selectByExample(pamsUserExample);
        return Ret.get().setData(pamsUserList).success();
    }


    @Override
    public Ret getPamsQuote(String projectGuid) {
        List<PamsQuoteDto> data =pamsPuoteDao.getPamsQuote(projectGuid);
        for(PamsQuoteDto dto:data){
           List<Tree> treeList = svnDao.getPamsSvn(dto.getProjectGuid());
           List<PamsClientDto> pamsClientDtos = pamsClientDao.getPamsClient(dto.getClientName());
           List<PamsMilestoneDto> milestoneDtos = new ArrayList<>();
           List<PamsMilestoneDto> milestoneList = milestoneDao.getPamsMilestone(dto.getProjectId());
            for(PamsMilestoneDto pamsMilestoneDto :milestoneList){
                boolean userFlag = milestoneDtos.stream().filter(item -> item.getProjectId().equals(pamsMilestoneDto.getProjectId())).findAny().isPresent();
                if(userFlag==false){
                    milestoneDtos.add(pamsMilestoneDto);
                }
            }
           dto.setSvnRows(treeList);
           dto.setClientRows(pamsClientDtos);
           dto.setMilestoneRows(milestoneDtos);
        }
        return Ret.get().setData(data).success();
    }

    public Ret getAll(String projectId,String isitAll){
        PamsDto pamsDto = new PamsDto();
        List<PamsQuoteDto> data = pamsPuoteDao.getPamsQuote(projectId);
        List<ProjectDto> projectDtos = new ArrayList<>();
        List<ClientDto> clientDtoList = new ArrayList<>();
        List<UserDto> userDtoList= new ArrayList<>();
        if(DataUtil.isNotEmpty(data)){
            for(PamsQuoteDto dto:data) {
                ProjectDto project = new ProjectDto();
                project.setId(dto.getId());
                project.setName(dto.getProjectName());
                project.setProjectId(dto.getProjectId());

                project.setType("项目");
                for (Map.Entry<String, Object> m : dto.getRows().entrySet()) {
                    if(m.getKey().equals("药物名称")){
                        if(DataUtil.isNotEmpty(m.getValue())){
                            project.setDrugName(m.getValue().toString());
                        }
                    }
                    if(m.getKey().equals("适应症")){
                        if(DataUtil.isNotEmpty(m.getValue())){
                            project.setAdapt(m.getValue().toString());
                        }
                    }
                    if(m.getKey().equals("创建时间")){
                        if(DataUtil.isNotEmpty(m.getValue())){
                            project.setCreationTime(m.getValue().toString());
                        }
                    }
                }
                projectDtos.add(project);

                List<PamsClientDto> pamsClientDtos = pamsClientDao.getPamsClient(dto.getClientName());

                if (DataUtil.isNotEmpty(pamsClientDtos)) {
                    for (PamsClientDto pamsClientDto : pamsClientDtos) {
                        ClientDto clientDto = new ClientDto();
                        boolean clientFlag= clientDtoList.stream().filter(item -> item.getClientName().equals(pamsClientDto.getClientName())).findAny().isPresent();
                        if (clientFlag==false) {
                            clientDto.setClientName(pamsClientDto.getClientName());
                            clientDto.setType("客户");
                            clientDto.setId(UUIDUtil.generateUUID());
                            for(Map.Entry<String, Object> m : pamsClientDto.getClientBasic().entrySet()){
                                if(DataUtil.isNotEmpty(m.getValue())){
                                    if(m.getKey().equals("客户来源")){
                                        clientDto.setSource(m.getValue().toString());
                                    }
                                    if(m.getKey().equals("地址-详细")){
                                        clientDto.setSite(m.getValue().toString());
                                    }
                                    if(m.getKey().equals("销售员")){
                                        clientDto.setSalesman(m.getValue().toString());
                                    }
                                }
                            }
                            List<PamsQuoteDto> pamsQuoteDtos = pamsPuoteDao.getClientPamsQuote(pamsClientDto.getClientName());
                            Map<String, List> listMap = new HashMap<>();
                            if (DataUtil.isNotEmpty(pamsQuoteDtos)) {
                                List<String> list = new ArrayList<>();
                                for (PamsQuoteDto pamsQuoteDto : pamsQuoteDtos) {
                                    boolean PamsFalg= projectDtos.stream().filter(item -> item.getProjectId().equals(pamsQuoteDto.getProjectId())).findAny().isPresent();
                                    if (PamsFalg==false) {
                                        ProjectDto projects = new ProjectDto();
                                        projects.setId(pamsQuoteDto.getId());
                                        projects.setName(pamsQuoteDto.getProjectName());
                                        projects.setProjectId(pamsQuoteDto.getProjectId());
                                        projects.setType("项目");
                                        projectDtos.add(projects);
                                    }
                                    list.add(pamsQuoteDto.getId());
                                    listMap.put(pamsClientDto.getClientName(), list);
                                    clientDto.setProjcetId(listMap);
                                }
                                clientDtoList.add(clientDto);
                            }
                        }
                    }
                }
                for(Map.Entry<String, Object> m : dto.getRows().entrySet()){
                    if (m.getKey().equals("项目经理")||m.getKey().equals("数据管理负责人")||m.getKey().equals("统计负责人")
                            ||m.getKey().equals("编程负责人")
                            ||m.getKey().equals("建库专员")
                            ||m.getKey().equals("医学编码")
                            ||m.getKey().equals("药物警戒")
                            ||m.getKey().equals("数据审核人")
                            ||m.getKey().equals("项目统计师")
                            ||m.getKey().equals("统计审核人")
                            ||m.getKey().equals("独立统计师")
                            ||m.getKey().equals("程序员")
                    ) {
                        if (DataUtil.isNotEmpty(m.getValue())) {
                            String[] name = m.getValue().toString().split(",");
                            if (DataUtil.isNotEmpty(name)) {
                                for (int i = 0; i < name.length; i++) {
                                    UserDto user = new UserDto();
                                    String names = name[i];
                                    boolean userFlag = userDtoList.stream().filter(item -> item.getName().equals(names)).findAny().isPresent();
                                    if (userFlag == false) {
                                        String key = "rows." + m.getKey();
                                        user.setId(UUIDUtil.generateUUID());
                                        user.setName(names);
                                        user.setType(m.getKey());
                                        PamsUserExample pamsUserExample = new PamsUserExample();
                                        pamsUserExample.createCriteria().andNameEqualTo(names);
                                        List<PamsUser> userList= pamsUserMapper.selectByExample(pamsUserExample);
                                        for(PamsUser pamsUser:userList){
                                            user.setDepartment(pamsUser.getSection());
                                            user.setKeyPost(pamsUser.getKeyPost());
                                            user.setMail(pamsUser.getMailbox());
                                        }
                                        List<PamsQuoteDto> pamsQuoteDtos = pamsPuoteDao.getNamePamsQuote(key, names);
                                        Map<String, List> listMap = new HashMap<>();
                                        List<String> list = new ArrayList<>();
                                        if (DataUtil.isNotEmpty(pamsQuoteDtos)) {
                                            for (PamsQuoteDto pamsQuoteDto : pamsQuoteDtos) {
                                                ProjectDto projects = new ProjectDto();
                                                boolean falg = projectDtos.stream().filter(item -> item.getProjectId().equals(pamsQuoteDto.getProjectId())).findAny().isPresent();
                                                if (falg == false) {
                                                    projects.setId(pamsQuoteDto.getId());
                                                    projects.setName(pamsQuoteDto.getProjectName());
                                                    projects.setType("项目");
                                                    projects.setProjectId(pamsQuoteDto.getProjectId());
                                                    for (Map.Entry<String, Object> ms : pamsQuoteDto.getRows().entrySet()){
                                                        if(DataUtil.isNotEmpty(ms   .getValue())){
                                                            if(ms.getKey().equals("药物名称")){
                                                                projects.setDrugName(ms.getValue().toString());
                                                            }
                                                            if(ms.getKey().equals("适应症")){
                                                                projects.setAdapt(ms.getValue().toString());
                                                            }
                                                            if(ms.getKey().equals("创建时间")){
                                                                projects.setCreationTime(ms.getValue().toString());
                                                            }
                                                        }
                                                    }
                                                    projectDtos.add(projects);

                                                    List<PamsClientDto> pamsClientDtosw = pamsClientDao.getPamsClient(pamsQuoteDto.getClientName());

                                                    if (DataUtil.isNotEmpty(pamsClientDtosw)) {
                                                        for (PamsClientDto pamsClientDto : pamsClientDtosw) {
                                                            ClientDto clientDto = new ClientDto();
                                                            boolean clientFlag = clientDtoList.stream().filter(item -> item.getClientName().equals(pamsClientDto.getClientName())).findAny().isPresent();
                                                            if (clientFlag == false) {
                                                                clientDto.setClientName(pamsClientDto.getClientName());
                                                                clientDto.setType("客户");
                                                                clientDto.setId(UUIDUtil.generateUUID());
                                                                for (Map.Entry<String, Object> mw : dto.getRows().entrySet()) {
                                                                    if (DataUtil.isNotEmpty(m.getValue())) {
                                                                        if (mw.getKey().equals("客户来源")) {
                                                                            clientDto.setSource(m.getValue().toString());
                                                                        }else
                                                                        if (mw.getKey().equals("地址-详细")) {
                                                                            clientDto.setSite(m.getValue().toString());
                                                                        }else
                                                                        if (mw.getKey().equals("销售员")) {
                                                                            clientDto.setSalesman(m.getValue().toString());
                                                                        }
                                                                    }
                                                                }
                                                                List<PamsQuoteDto> pamsQuoteDtosw = pamsPuoteDao.getClientPamsQuote(pamsClientDto.getClientName());
                                                                Map<String, List> listMaps = new HashMap<>();
                                                                if (DataUtil.isNotEmpty(pamsQuoteDtosw)) {
                                                                    List<String> lists = new ArrayList<>();
                                                                    for (PamsQuoteDto pamsQuoteDtow : pamsQuoteDtosw) {
                                                                        lists.add(pamsQuoteDtow.getId());
                                                                        listMaps.put(pamsQuoteDtow.getClientName(), lists);
                                                                        clientDto.setProjcetId(listMaps);
                                                                    }
                                                                }
                                                                clientDtoList.add(clientDto);
                                                            }
                                                        }
                                                    }
                                                }
                                                list.add(pamsQuoteDto.getId());
                                            }
                                            listMap.put(name[i], list);
                                            user.setProjcetId(listMap);
                                        }
                                    }
                                    if (DataUtil.isNotEmpty(user.getId())) {
                                        userDtoList.add(user);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        if(DataUtil.isNotEmpty(isitAll)){
            List<PamsQuoteDto> dataAll = pamsPuoteDao.allPamsQuote();
            for (PamsQuoteDto pamsQuoteDto:dataAll){
                boolean proFlag = projectDtos.stream().filter(item -> item.getProjectId().equals(pamsQuoteDto.getProjectId())).findAny().isPresent();
                if(proFlag==false){
                    ProjectDto project = new ProjectDto();
                    project.setId(pamsQuoteDto.getId());
                    project.setName(pamsQuoteDto.getProjectName());
                    project.setProjectId(pamsQuoteDto.getProjectId());
                    boolean clientFalg = clientDtoList.stream().filter(item -> item.getClientName().equals(pamsQuoteDto.getClientName())).findAny().isPresent();
                    if(clientFalg==false){
                        ClientDto clientDto = new ClientDto();
                        clientDto.setClientName(pamsQuoteDto.getClientName());
                        List<PamsClientDto> pamsClientDtos = pamsClientDao.getPamsClient(pamsQuoteDto.getClientName());
                        for(PamsClientDto pamsClientDto : pamsClientDtos){
                            boolean clientFlag= clientDtoList.stream().filter(item -> item.getClientName().equals(pamsClientDto.getClientName())).findAny().isPresent();
                            if (clientFlag==false) {
                                clientDto.setClientName(pamsClientDto.getClientName());
                                clientDto.setType("客户");
                                clientDto.setId(UUIDUtil.generateUUID());
                                List<PamsQuoteDto> pamsQuoteDtosw = pamsPuoteDao.getClientPamsQuote(pamsClientDto.getClientName());
                                Map<String, List> listMaps = new HashMap<>();
                                if (DataUtil.isNotEmpty(pamsQuoteDtosw)) {
                                    List<String> lists = new ArrayList<>();
                                    for (PamsQuoteDto pamsQuoteDtow : pamsQuoteDtosw) {
                                        lists.add(pamsQuoteDtow.getId());
                                        listMaps.put(pamsQuoteDtow.getClientName(), lists);
                                        clientDto.setProjcetId(listMaps);
                                    }
                                }

                                for(Map.Entry<String, Object> m : pamsClientDto.getClientBasic().entrySet()){
                                    if(DataUtil.isNotEmpty(m.getValue())){
                                        if(m.getKey().equals("客户来源")){
                                            clientDto.setSource(m.getValue().toString());
                                        }
                                        if(m.getKey().equals("地址-详细")){
                                            clientDto.setSite(m.getValue().toString());
                                        }
                                        if(m.getKey().equals("销售员")){
                                            clientDto.setSalesman(m.getValue().toString());
                                        }
                                    }
                                }
                                clientDtoList.add(clientDto);
                            }
                        }
                    }
                    for (Map.Entry<String, Object> m : pamsQuoteDto.getRows().entrySet()){
                        if(DataUtil.isNotEmpty(m.getValue())){
                            if(m.getKey().equals("药物名称")){
                                    project.setDrugName(m.getValue().toString());
                            }
                            if(m.getKey().equals("适应症")){
                                    project.setAdapt(m.getValue().toString());
                            }
                            if(m.getKey().equals("创建时间")){
                                    project.setCreationTime(m.getValue().toString());
                            }
                            if (m.getKey().equals("项目经理")||m.getKey().equals("数据管理负责人")||m.getKey().equals("统计负责人")
                                            ||m.getKey().equals("编程负责人")
                                            ||m.getKey().equals("建库专员")
                                            ||m.getKey().equals("医学编码")
                                            ||m.getKey().equals("药物警戒")
                                            ||m.getKey().equals("数据审核人")
                                            ||m.getKey().equals("项目统计师")
                                            ||m.getKey().equals("统计审核人")
                                            ||m.getKey().equals("独立统计师")
                                            ||m.getKey().equals("程序员")
                                    ) {
                                String[] name = m.getValue().toString().split(",");
                                for (int i = 0; i < name.length; i++) {
                                    UserDto user = new UserDto();
                                    String names = name[i];
                                    boolean userFlag = userDtoList.stream().filter(item -> item.getName().equals(names)).findAny().isPresent();
                                    if(userFlag==false){
                                        user.setId(UUIDUtil.generateUUID());
                                        user.setName(names);
                                        user.setType(m.getKey());
                                        PamsUserExample pamsUserExample = new PamsUserExample();
                                        pamsUserExample.createCriteria().andNameEqualTo(names);
                                        List<PamsUser> userList= pamsUserMapper.selectByExample(pamsUserExample);
                                        for(PamsUser pamsUser:userList){
                                            user.setDepartment(pamsUser.getSection());
                                            user.setKeyPost(pamsUser.getKeyPost());
                                            user.setMail(pamsUser.getMailbox());
                                        }
                                        List<PamsQuoteDto> pamsQuoteDtos = pamsPuoteDao.getNamePamsQuote("rows."+m.getKey(), names);
                                        Map<String, List> listMap = new HashMap<>();
                                        List<String> list = new ArrayList<>();
                                        if (DataUtil.isNotEmpty(pamsQuoteDtos)) {
                                            for (PamsQuoteDto pamsQuoteDtosw : pamsQuoteDtos) {
                                                list.add(pamsQuoteDtosw.getId());
                                            }
                                        }
                                        listMap.put(name[i], list);
                                        user.setProjcetId(listMap);
                                        userDtoList.add(user);
                                    }
                                }
                             }
                        }
                    }
                    projectDtos.add(project);
                }
            }
        }
        if(DataUtil.isEmpty(isitAll)){
            
        }
        pamsDto.setProjectDtoList(projectDtos);
        pamsDto.setClientDtoList(clientDtoList);
        pamsDto.setUserDtoList(userDtoList);
        return Ret.get().setData(pamsDto).success();
        }
        
    
    public Ret getPlan(String key,String name){
        System.out.println("key等于"+key);
        List<PamsQuoteDto> data = pamsPuoteDao.getNamePamsQuotes(key,name);
        Map<String,Object> map = new HashMap<>();
        List<ProjectDto> projectDtos = new ArrayList<>();
        for(PamsQuoteDto dto:data) {
            List<PamsMilestoneDto> milestoneList = milestoneDao.getPamsMilestone(dto.getProjectId());
            int normal = 0;//正常状态
            int onTime = 0;//按期完成
            int toStartThe = 0;
            int abnormal = 0;//异常进行
            int stopNum = 0;
            int entNum = 0;
            int rests = 0;
            Map<String,Object> projectMap = new HashMap<>();
            for (PamsMilestoneDto pamsMilestoneDto : milestoneList) {
                for (Map.Entry<String, Object> m : pamsMilestoneDto.getRows().entrySet()) {
                    ProjectDto projectDto=new ProjectDto();
                    if (m.getKey().equals("项目状态")) {
                        if (DataUtil.isNotEmpty(m.getValue())) {
                            String type = m.getValue().toString();
                                boolean proFlag = projectDtos.stream().filter(
                                                item -> item.getId().equals(pamsMilestoneDto.getId())
                                                        ).findAny().isPresent();
                            boolean proFlags = projectDtos.stream().filter(
                                    item -> item.getType().equals(type)).findAny().isPresent();
                                if(proFlag==false&&proFlags==false){
                                    projectDto.setId(pamsMilestoneDto.getProjectId());
                                    projectDto.setType(type);
                                }

                        } else {
                            boolean proFlag = projectDtos.stream().filter(
                                    item -> item.getId().equals(pamsMilestoneDto.getId())
                                            &&item.getType().equals("其他")).findAny().isPresent();
                            if(proFlag==false){
                                projectDto.setId(pamsMilestoneDto.getProjectId());
                                projectDto.setType("其他");
                            }
                        }
                    }
                    if(DataUtil.isNotEmpty(projectDto.getId())){
                        projectDtos.add(projectDto);
                    }
                }
            }
            for(ProjectDto projectDto: projectDtos){
                if(projectDto.getType().equals("正常进行")){
                    normal++;
                }
                if(projectDto.getType().equals("按期完成")){
                    onTime++;
                }
                if(projectDto.getType().equals("待启动")){
                    toStartThe++;
                }
                if(projectDto.getType().equals("异常进行")){
                    abnormal++;
                }
                if(projectDto.getType().equals("暂停")){
                    stopNum++;
                }
                if(projectDto.getType().equals("终止")){
                    entNum++;
                }
                if(projectDto.getType().equals("其他")){
                    rests++;
                }
            }
            map.put("正常进行", normal);
            map.put("按期完成", onTime);
            map.put("待启动", toStartThe);
            map.put("异常进行", abnormal);
            map.put("暂停", stopNum);
            map.put("终止", entNum);
            map.put("其他", rests);
        }
        return  Ret.get().setData(map).success();
    }

    public Ret getNameMilestone(String key,String name,String type,String projectId,String creationTime){
        List<PamsQuoteDto> data = pamsPuoteDao.getConditionPamsQuotes(key,name,projectId,creationTime);
        List<PamsQuoteDto> pamsQuoteDtos= new ArrayList<>();
        if(DataUtil.isNotEmpty(type)){
            for(PamsQuoteDto dto:data) {
                List<PamsMilestoneDto> milestoneList = milestoneDao.getConditionMilestone(dto.getProjectId(),type);
                for(PamsMilestoneDto pamsMilestoneDto :milestoneList){
                    if(dto.getProjectId().equals(pamsMilestoneDto.getProjectId())){
                        pamsQuoteDtos.add(dto);
                    }
                }
            }
        }else{
            pamsQuoteDtos.addAll(data);
        }

        return  Ret.get().setData(pamsQuoteDtos).success();
    }

    public Ret getMilestone(String key,String name){
        List<PamsQuoteDto> data = pamsPuoteDao.getNamePamsQuotes(key,name);
        List<PamsMilestoneDto> milestoneDtos = new ArrayList<>();
        for(PamsQuoteDto dto:data) {
            List<PamsMilestoneDto> milestoneList = milestoneDao.getPamsMilestones(dto.getProjectId());
            for(PamsMilestoneDto pamsMilestoneDto :milestoneList){
                boolean userFlag = milestoneDtos.stream().filter(item -> item.getProjectId().equals(pamsMilestoneDto.getProjectId())).findAny().isPresent();
                if(userFlag==false){
                    milestoneDtos.add(pamsMilestoneDto);
                }
            }
        }
        return Ret.get().setData(milestoneDtos).success();
    }

    @Override
    public Ret ListPamsClient(PamsClientQuery pamsClientQuery) {
        try{
            PageResult<PamsClientDto> pageData = pamsClientDao.listPamsClient(pamsClientQuery);

            return Ret.get().setData(pageData).success();
        }catch (Exception e){
            log.error("listSdtmDataByPage exception => " , e);
        }
        return Ret.get().faild();
    }
}
